home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / mimelib / group.h < prev    next >
Encoding:
C/C++ Source or Header  |  2007-05-14  |  7.9 KB  |  205 lines

  1. //=============================================================================
  2. // File:       group.h
  3. // Contents:   Declarations for DwGroup
  4. // Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
  5. // WWW:        http://www.fwb.gulf.net/~dwsauder/mimepp.html
  6. //
  7. // Copyright (c) 1996, 1997 Douglas W. Sauder
  8. // All rights reserved.
  9. //
  10. // IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
  11. // INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
  12. // THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
  13. // HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14. //
  15. // DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
  16. // NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  17. // PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
  18. // BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
  19. // SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  20. //
  21. //=============================================================================
  22.  
  23. #ifndef DW_GROUP_H
  24. #define DW_GROUP_H
  25.  
  26. #ifndef DW_CONFIG_H
  27. #include <mimelib/config.h>
  28. #endif
  29.  
  30. #ifndef DW_STRING_H
  31. #include <mimelib/string.h>
  32. #endif
  33.  
  34. #ifndef DW_MAILBOX_H
  35. #include <mimelib/mailbox.h>
  36. #endif
  37.  
  38. #ifndef DW_MBOXLIST_H
  39. #include <mimelib/mboxlist.h>
  40. #endif
  41.  
  42. #ifndef DW_ADDRESS_H
  43. #include <mimelib/address.h>
  44. #endif
  45.  
  46. //=============================================================================
  47. //+ Name DwGroup -- Class representing an RFC-822 address group
  48. //+ Description
  49. //. {\tt DwGroup} represents a {\it group} as described in RFC-822.  A group
  50. //. contains a group name and a (possibly empty) list of {\it mailboxes}.
  51. //. In MIME++, a {\tt DwGroup} object contains a string for the group name
  52. //. and a {\tt DwMailboxList} object for the list of mailboxes.
  53. //.
  54. //. In the tree (broken-down) representation of message, a {\tt DwGroup}
  55. //. object may be only an intermediate node, having both a parent and a single
  56. //. child node.  Its parent node must be a {\tt DwField} or a
  57. //. {\tt DwAddressList}.  Its child is a {\tt DwMailboxList}.
  58. //.
  59. //. A {\tt DwGroup} is a {\tt DwAddress}, and therefore it can be included
  60. //. in a list of {\tt DwAddress} objects.  To get the next {\tt DwAddress}
  61. //. object in a list, use the inherited member function
  62. //. {\tt DwAddress::Next()}.
  63. //=============================================================================
  64. // Last updated 1997-08-24
  65. //+ Noentry ~DwGroup _PrintDebugInfo
  66.  
  67.  
  68. class DW_EXPORT DwGroup : public DwAddress {
  69.  
  70. public:
  71.  
  72.     DwGroup();
  73.     DwGroup(const DwGroup& aGroup);
  74.     DwGroup(const DwString& aStr, DwMessageComponent* aParent=0);
  75.     //. The first constructor is the default constructor, which sets the
  76.     //. {\tt DwGroup} object's string representation to the empty string
  77.     //. and sets its parent to {\tt NULL}.
  78.     //.
  79.     //. The second constructor is the copy constructor, which performs
  80.     //. a deep copy of {\tt aGroup}.
  81.     //. The parent of the new {\tt DwGroup} object is set to {\tt NULL}.
  82.     //.
  83.     //. The third constructor copies {\tt aStr} to the {\tt DwGroup}
  84.     //. object's string representation and sets {\tt aParent} as its parent.
  85.     //. The virtual member function {\tt Parse()} should be called immediately
  86.     //. after this constructor in order to parse the string representation.
  87.     //. Unless it is {\tt NULL}, {\tt aParent} should point to an object of
  88.     //. a class derived from {\tt DwField} or {\tt DwAddressList}.
  89.  
  90.     virtual ~DwGroup();
  91.  
  92.     const DwGroup& operator = (const DwGroup& aGroup);
  93.     //. This is the assignment operator, which performs a deep copy of
  94.     //. {\tt aGroup}.  The parent node of the {\tt DwGroup} object
  95.     //. is not changed.
  96.  
  97.     virtual void Parse();
  98.     //. This virtual function, inherited from {\tt DwMessageComponent},
  99.     //. executes the parse method for {\tt DwGroup} objects. The parse
  100.     //. method creates or updates the broken-down representation from the
  101.     //. string representation.  For {\tt DwGroup} objects, the parse method
  102.     //. parses the string representation to extract the group name and to
  103.     //. create a {\tt DwMailboxList} object from the list of mailboxes. This
  104.     //. member function also calls the {\tt Parse()} member function of
  105.     //. the {\tt DwMailboxList} object it creates.
  106.     //.
  107.     //. You should call this member function after you set or modify the
  108.     //. string representation, and before you access the group name or the
  109.     //. mailbox list.
  110.     //.
  111.     //. This function clears the is-modified flag.
  112.  
  113.     virtual void Assemble();
  114.     //. This virtual function, inherited from {\tt DwMessageComponent},
  115.     //. executes the assemble method for {\tt DwGroup} objects. The
  116.     //. assemble method creates or updates the string representation from
  117.     //. the broken-down representation.  That is, the assemble method
  118.     //. builds the string representation from its group name and mailbox
  119.     //. list.  Before it builds the string representation, this function
  120.     //. calls the {\tt Assemble()} member function of its contained
  121.     //. {\tt DwMailboxList} object.
  122.     //.
  123.     //. You should call this member function after you set or modify either
  124.     //. the group name or the contained {\tt DwMailboxList} object, and
  125.     //. before you retrieve the string representation.
  126.     //.
  127.     //. This function clears the is-modified flag.
  128.  
  129.     virtual DwMessageComponent* Clone() const;
  130.     //. This virtual function, inherited from {\tt DwMessageComponent},
  131.     //. creates a new {\tt DwGroup} on the free store that has the same
  132.     //. value as this {\tt DwGroup} object.  The basic idea is that of
  133.     //. a virtual copy constructor.
  134.  
  135.     const DwString& GroupName() const;
  136.     //. Returns the name of the group.
  137.  
  138.     const DwString& Phrase() const;
  139.     //. Returns the name of the phrase part of a group as described in
  140.     //. RFC-822.  The phrase is the same as the group name.
  141.  
  142.     void SetGroupName(const DwString& aName);
  143.     //. Sets the name of the group.
  144.  
  145.     void SetPhrase(const DwString& aPhrase);
  146.     //. Sets the name of the phrase part of a group as described in RFC-822.
  147.     //. The phrase is the same as the group name.
  148.  
  149.     DwMailboxList& MailboxList() const;
  150.     //. Provides access to the list of mailboxes that is part of a group as
  151.     //. described in RFC-822.
  152.  
  153.     static DwGroup* NewGroup(const DwString& aStr,
  154.         DwMessageComponent* aParent);
  155.     //. Creates a new {\tt DwGroup} object on the free store.
  156.     //. If the static data member {\tt sNewGroup} is {\tt NULL},
  157.     //. this member function will create a new {\tt DwGroup}
  158.     //. and return it.  Otherwise, {\tt NewGroup()} will call
  159.     //. the user-supplied function pointed to by {\tt sNewGroup},
  160.     //. which is assumed to return an object from a class derived from
  161.     //. {\tt DwGroup}, and return that object.
  162.  
  163.     //+ Var sNewGroup
  164.     static DwGroup* (*sNewGroup)(const DwString&, DwMessageComponent*);
  165.     //. If {\tt sNewGroup} is not {\tt NULL}, it is assumed to point to a
  166.     //. user-supplied function that returns an object from a class derived from
  167.     //. {\tt DwGroup}.
  168.  
  169. protected:
  170.  
  171.     DwMailboxList* mMailboxList;
  172.     //. Points to the {\tt DwMailboxList} object.
  173.  
  174.  
  175. private:
  176.  
  177.     DwString mGroupName;
  178.     static const char* const sClassName;
  179.  
  180. public:
  181.  
  182.     virtual void PrintDebugInfo(std::ostream& aStrm, int aDepth=0) const;
  183.     //. This virtual function, inherited from {\tt DwMessageComponent},
  184.     //. prints debugging information about this object to {\tt aStrm}.
  185.     //. It will also call {\tt PrintDebugInfo()} for any of its child
  186.     //. components down to a level of {\tt aDepth}.
  187.     //.
  188.     //. This member function is available only in the debug version of
  189.     //. the library.
  190.  
  191.     virtual void CheckInvariants() const;
  192.     //. Aborts if one of the invariants of the object fails.  Use this
  193.     //. member function to track down bugs.
  194.     //.
  195.     //. This member function is available only in the debug version of
  196.     //. the library.
  197.  
  198. protected:
  199.  
  200.     void _PrintDebugInfo(std::ostream& aStrm) const;
  201.  
  202. };
  203.  
  204. #endif
  205.